package edu.wtbu.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import edu.wtbu.pojo.Result;
import edu.wtbu.dao.UsersDao;
import edu.wtbu.pojo.Users;


@WebServlet("/Login")
public class Test extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public Test() {
        super();
        // TODO Auto-generated constructor stub
    }

    
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String email=request.getParameter("password");
		String password=request.getParameter("password");
		
		Users user=new Users();
		user.setEmail("behappy@vip.sina.com");
		user.setPassword("123456");
		
		List<Users> list=UsersDao.findByEmailAndPassword(user);
		
		edu.wtbu.pojo.Result result=new edu.wtbu.pojo.Result("success",null,list);
		String msg=JSON.toJSONString(result);
		response.getWriter().append(msg);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
